﻿using System;
using System.Linq;
using System.Text;
using System.Collections;

namespace TrainningWeekend
{
    class Program
    {
        static void Main(string[] args)
        {
            Student s = new Student(6, "six");
            Student s2 = new Student();
            s2.age = 7;
            s2.name = "seven";
            Student s3 = new Student();
            s3.age = 1;
            s3.name = "one";

            Class c = new Class();

            c.Add(s);
            c.Add(s2);
            c.Add(s3);
            //c.students.Sort();

            //for (int i = 0; i < c.students.Count; i++)
            //{
            //    Student stu = (Student)c.students[i];
            //    Console.WriteLine(stu);
            //}

            ArrayList list = new ArrayList();
            list.Add(5);
            list.Add(7);
            list.Add(1);
            list.Add(-1);
            list.Add(100);
            //list.Sort();

            //foreach (object o in list)
            //{
            //    Console.WriteLine(o);
            //}

            //if (list.Contains(6))
            //{
            //    Console.WriteLine("在里面");
            //}
            //else
            //{
            //    Console.WriteLine("不在里面");
            //}

            Student student = c[2];
            //c.students[2];
            Console.WriteLine(student);

            c[2] = new Student();

            Student student2 = c["johnny"];
            
        }
    }

    class Person
    {
        public string name;
        public DateTime dateOfBirth;
        private Gender gender;
        public int height;

        public void Talk()
        {
            Console.WriteLine("I'm talking to myself");
        }

        public void Talk(string content)
        {
            Console.WriteLine(content);
        }

        public void Talk(Person p)
        {
            Console.WriteLine("I'm talking with " + p.name);
        }

        public int Age
        {
            get
            {
                return DateTime.Now.Year - dateOfBirth.Year;
            }

        }

        public Gender Xingbie
        {
            get
            {
                Console.WriteLine("取值");
                return gender;
            }
            set
            {
                Console.WriteLine("赋值");
                gender = value;
            }
        }

        public override string ToString()
        {
            return "姓名：" + name + "，年龄：" + Age + "，身高：" + height;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Employee))
            {
                return false;
            }
            Employee e = (Employee)obj;
            return e.name == name;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public static bool operator ==(Person e1, Person e2)
        {
            return e1.height == e2.height;
        }

        public static bool operator !=(Person e1, Person e2)
        {
            return e1.height != e2.height;
        }

    }

    struct Salary
    {
        public bool[] month;
        public float daySalary;
        public int days;
        public string name;

        public Salary(string name, int days, float daySalary)
        {
            this.name = name;
            this.days = days;
            this.daySalary = daySalary;
            month = new bool[days];
        }

        public float GetTotalSalary()
        {
            int workDays = 0;
            for (int i = 0; i < month.Length; i++)
            {
                bool work = month[i];
                if (work)
                {
                    workDays++;
                }

            }
            return workDays * daySalary;
        }

        public override string ToString()
        {
            return "员工：" + name + "的工资总额是" + GetTotalSalary();
        }

        public static bool operator ==(Salary s1, Salary s2)
        {
            return s1.GetTotalSalary() == s2.GetTotalSalary();
        }

        public static bool operator !=(Salary s1, Salary s2)
        {
            return s1.GetTotalSalary() != s2.GetTotalSalary();
        }

    }

    class Customer : Person
    {
        public int Credit
        {
            set;
            get;
        }

        public void Talk()
        {
            Console.WriteLine("Customer is talking");
        }

    }

    class Employee : Person
    {
        public int Salary
        {
            get
            {
                return 0;
            }
        }
    }

    enum Gender
    {
        Male,Female, Bigender, Nongender
    }

    class Rect
    {
        private int length;
        public int width;

        public int Area
        {
            get
            {
                return length * width;
            }
            
        }

        public int Length
        {
            set
            {
                if (value < 3)
                    length = 3;
                else
                    length = value;
            }
            get
            {
                return length;
            }
        }
    }

}
